package com.murfrosoft.entity.AirHockey;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;

public class CompPaddle extends Paddle {

	@Override
	public void move(int width,int height, float puckX, float puckY) {
		/* UPDATE COMPUTER PADDLE POSITION */
		
		/* NEW COMPUTER AI!!!! */
		if( positionX < puckX ){
			positionX += velocityX;
		}
		else{
			positionX -= velocityX;
		}
		
		/* if puck is on our side of table, move torward it, otherwise, move backwards */
		if( puckY < height/2 ){
			if( positionY < puckY && positionY < (height/2 - radius) ){
				positionY += velocityY;
			}
			else{
				if( positionY > 1.1f*radius ){
					positionY -= velocityY;
				}
			}
		}
		else{
			if( positionY > 1.5f*radius ){
				positionY -= velocityY;
			}
		}
		
		
		/*
		positionX = (positionX + velocityX);
		positionY = positionY + velocityY;
		if( positionX < 20 + radius || positionX > width - 20 - radius ){
			velocityX *= -1;
		}
		if( positionY < 20 + radius || positionY > height/2 - 20 - radius ){
			velocityY *= -1;
		}
		*/
		
	}

	@Override
	public void draw(Canvas canvas) {
		/* DRAW COMPUTER PADDLE */
		Paint paddle_color3 = new Paint();
		paddle_color3.setColor(Color.rgb(0, 0, 255));
		Paint paddle_color4 = new Paint();
		paddle_color4.setColor(Color.rgb(100, 100, 255));
		paddle_color4.setAntiAlias(true);
		paddle_color3.setAntiAlias(true);
	
		canvas.drawCircle(positionX,positionY, radius, paddle_color3);
		canvas.drawCircle(positionX,positionY, radius/2, paddle_color4);
		//canvas.drawBitmap(bitmap, positionX-radius, positionY-radius, paddle_color4);
		
	}



}
